package com.lintcode.solution;

public class Solution_61 {
    public static void main(String[] args) {
        int[] a = { 1, 1, 1, 1 };
        for (int i : searchRange(a, 1)) {
            System.out.println(i);
        }
    }
    
    public static int[] searchRange(int[] A, int target) {
        int[] result = { - 1, - 1 };
        boolean flag = true;
        for (int i = 0; i < A.length; i++) {
            if (flag && A[ i ] == target) {
                result[ 0 ] = i;
                result[ 1 ] = i;
                flag = false;
            } else if (! flag && A[ i ] == target) {
                result[ 1 ] = i;
            }
        }
        return result;
    }
}
